//
//  CmtRecommendModel.m
//  Products_B
//
//  Created by lanou on 16/5/28.
//  Copyright © 2016年 朋学友. All rights reserved.
//

#import "CmtRecommendModel.h"
#import "CmtRecommendTopics.h"
#import "CmtRecommendComment.h"
@implementation CmtRecommendModel
-(instancetype)init{

    self = [super init];
    if (self) {
        
        self.topics = [[NSMutableArray alloc] initWithCapacity:1];
        self.comment = [[NSMutableArray alloc] initWithCapacity:1 ];
        self.like = [[NSMutableArray alloc] initWithCapacity:1];
        
    }
    return self;
}



-(void)setValue:(id)value forUndefinedKey:(NSString *)key{

    if ([key isEqualToString:@"id"]) {
        __id = value;
    }
    
    if ([key isEqualToString:@"topics"]) {
        
        for (NSDictionary *dic in value) {
            CmtRecommendTopics *model = [[CmtRecommendTopics alloc]init];
            [model setValuesForKeysWithDictionary:dic];
            [self.topics addObject:model];
        }
        
    }
     if ([key isEqualToString:@"comment"]) {
        for (NSDictionary *dic in value) {
           CmtRecommendComment *model = [[CmtRecommendComment alloc]init];
        [model setValuesForKeysWithDictionary:dic];
        [self.comment addObject:model];
        }
    }
   if ([key isEqualToString:@"like"]) {
        for (NSDictionary *dic in value) {
            CmtRecommendLike *model = [[CmtRecommendLike alloc]init];
            [model setValuesForKeysWithDictionary:dic];
            [self.like addObject:model];
            
//            NSLog(@"like.count = %ld",self.like.count);
        }
    }
    else{
        [super setValue:value forUndefinedKey:key];
    }
}

@end
